package com.cjzuji.rental.Config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

import java.util.concurrent.Executor;

@Configuration
public class ThreadPoolConfig {
    @Bean("platformTaskExecutor")
    public Executor platformTaskExecutor() {
        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
        // 核心线程数
        executor.setCorePoolSize(5);
        // 最大线程数
        executor.setMaxPoolSize(10);
        //队列容量
        executor.setQueueCapacity(50);
        //线程名称前缀
        executor.setThreadNamePrefix("platform-thread-");
        //线程空闲时间
        executor.setKeepAliveSeconds(60);
        //初始化
        executor.initialize();
        return executor;
    }


}
